/**
 * Created by loso on 2017/3/5.
 */
public class _520_DetectCapital {

    public static void main(String[] args) {

    }

    public boolean detectCapitalUsenew(String word){
        return word.matches("[A-Z]+|[a-z]+|[A-Z][a-z]+");
    }

    public boolean detectCapitalUse(String word) {
        char first = word.charAt(0);
        if (word.replaceAll("[a-z]","").isEmpty())  {
            return true;
        }
        if (word.replaceAll("[A-Z]","").isEmpty()){
            return true;
        }
        if (first<='Z' && first >= 'A'){
            if (word.substring(1).replaceAll("[a-z]","").isEmpty())  {
                return true;
            }
        }
        return false;
    }
}
